<?php
/* @var $this TrxReceiptController */
/* @var $model TrxReceipt */
/* @var $form TbActiveForm */
?>

<div class="form">

    <?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm', array(
	'id'=>'trx-receipt-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

    <p class="help-block">Fields with <span class="required">*</span> are required.</p>

    <?php echo $form->errorSummary($model); ?>

            <div class="row">
	<div class="col-md-12">
						<div class="widget box">
							<div class="widget-header">
								
								<h4><i class="icon-reorder"></i>Tgl. Transaksi </h4>
								<div class="controls">
				<div class="input-group">
				 <?php echo $form->textField($model,'tgl_transaksi', array('class'=>'form-control input-width-small','data-mask'=>"99/99/9999",'value'=>date('d-m-Y'))); ?>
				</div>
								</div>
								<div class="toolbar no-padding">
									<div class="btn-group">
										<span class="btn btn-xs widget-collapse"><i class="icon-angle-down"></i></span>
									</div>
								</div>
							</div>
							<div class="widget-content no-padding">
<table class="table table-hover table-striped table-bordered table-highlight-head">
	<thead>
		<tr>
			<th>No</th>
			<th>Jenis Trx</th>
			<th>DN/CN</th>
			<th>Nominal</th>
			<th>Keterangan</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>1</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_1','onChange'=>'enableNota(1)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_1','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,1)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_1','readonly'=>true)); ?>
				<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_1" />
				</div>
			</td>
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>2</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_2','onChange'=>'enableNota(2)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_2','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,2)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_2','readonly'=>true)); ?>
					<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_2" />
				</div>
			</td>
			
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
		
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>3</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_3','onChange'=>'enableNota(3)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_3','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,3)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_3','readonly'=>true)); ?>
				<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_3" />	
				</div>
			</td>
		
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
			
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>4</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_4','onChange'=>'enableNota(4)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_4','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,4)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_4','readonly'=>true)); ?>
					<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_4" />
				</div>
			</td>
			
			
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
			
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>5</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_5','onChange'=>'enableNota(5)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_5','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,5)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_5','readonly'=>true)); ?>
					<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_5" />
				</div>
			</td>
			
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
		
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>6</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_6','onChange'=>'enableNota(6)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_6','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,6)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_6','readonly'=>true)); ?>
					<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_6" />
				</div>
			</td>
			
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
			
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>7</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_7','onChange'=>'enableNota(7)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_7','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,7)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_7','readonly'=>true)); ?>
					<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_7" />
				</div>
			</td>
			
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
			
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>8</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_8','onChange'=>'enableNota(8)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_8','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,8)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_8','readonly'=>true)); ?>
				<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_8" />	
				</div>
			</td>
			
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
			
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>9</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_9','onChange'=>'enableNota(2)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_9','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,9)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_9','readonly'=>true)); ?>
					<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_9" />
				</div>
			</td>
			
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>
		
			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td>10</td>
			<td>
			<?php echo $form->dropDownList($model, 'jns_trx', array(0 => "Pilih",1 => "Premi", 2 => "Non Premi", 3 => "Lain-lain"),array('class'=>'form-control input-width-small','id'=>'jns_trx_10','onChange'=>'enableNota(10)')); ?>
			</td>
			<td>
				<div class="input-group">
				 <?php echo $form->textField($model,'nota_note',array('class'=>'form-control input-width-medium','id'=>'nota_note_10','maxlength'=>50,'style'=>'float:left','readonly'=>true,'onkeydown'=>"showData(event,10)",'name'=>'nota_note[]')); ?>
				 <?php echo $form->hiddenField($model, 'no_nota_id',array('class'=>'form-control input-width-small','id'=>'no_nota_id_10','readonly'=>true)); ?>
					<input type="hidden" name="status_hg_nh[]" id="status_hg_nh_10" />
				</div>
			</td>
			
			<td>
				<?php echo $form->textField($model,'nominal', array('class'=>'form-control input-width-small','name'=>'nominal[]')); ?>
			</td>

			<td>
				<?php echo $form->textArea($model,'keterangan', array('class'=>'form-control input-width-small','name'=>'keterangan[]')); ?>
			</td>
		</tr>
		<tr>
			<td colspan="3" align="right"> <input type="button" value="Total" class="btn btn-primary" id="btn_total"></td>
			<td colspan="2"> <b><i> Rp. <label id="lbl_total"></label> </i></b></td>
		</tr>
	</tbody>
</table>


							</div>
						</div>
					</div>
	</div>

        <div class="form-actions">
        <?php echo TbHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array(
		    'color'=>TbHtml::BUTTON_COLOR_PRIMARY,
		    'size'=>TbHtml::BUTTON_SIZE_LARGE,
		)); ?>
    </div>

    <?php $this->endWidget(); ?>

</div><!-- form -->


<div id="myModal" class="modal fade in" style="display: none;" aria-hidden="false">
												<div class="modal-dialog" style="width:700px;">
													<div class="modal-content">
														<div class="modal-header">
															<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
															<h4 class="modal-title">Pilih Nomor Nota</h4>
														</div>
														<div class="modal-body">
															
							<?php //echo $this->renderPartial('//trxReceipt/_viewAllclient', array('model'=>$model3)); ?> 
														</div>
														<div class="modal-footer">
															<button data-dismiss="modal" class="btn btn-default" type="button">Close</button>
															<button id="btnTest" data-dismiss="modal" class="btn btn-primary" type="button">Pilih</button>
														</div>
													</div><!-- /.modal-content -->
												</div><!-- /.modal-dialog -->
</div>

	
<script type="text/javascript">
function showData(e,id){
	/*var code = e.keyCode || e.which;
	  if (code == 9){
		//alert($("#nota_note_"+id).val());
			$.ajax({
			type:"POST",
            url:"<?php echo Yii::app()->createUrl('/TrxReceipt/showTagihan'); ?>",
			data:"id="+id+"&no_nota="+$("#nota_note_"+id).val(),
			dataType:"json",
            success:function(data){
				if(data.id==""){
					alert('No Nota Tidak Sesuai, Cek Kembali');
					$("#nota_note_"+id).focus();
				}else{
					if(data.code=='IDR'){
						var isi = data.code+' '+data.final_nominal;
					}else{
						var isi = data.code+' '+data.nominal+' <br/> Konversi : '+ 'IDR '+data.final_nominal;
					}
					$("#lbl_tagihan_"+id).html(isi);
					$("#no_nota_id_"+id).val(data.id);
					$("#status_hg_nh_"+id).val(data.jns_insurance);
				}
			}
		});
	  }//end if */
}
 
function enableNota(id){
	if($("#jns_trx_"+id).val() != '0'){
		$("#nota_note_"+id).attr("readonly",false);
		$("#nota_note_"+id).focus();
	}else{
		$("#nota_note_"+id).attr("readonly",false);
		$("#nota_note_"+id).focus();
	}
	
}

$("#btnTest").click(function()
{
	
	var nil = "";
    nil = $('input:radio[name=user]:checked').val();
   $("#mst_client_id_1").val(nil);
   $("#client_name_1").val($('input:radio[name=user]:checked').attr('nama_client'));
}); 

$("#btn_total").click(function()
{
	var total = 0.0;
	$('input[name="nominal[]"]').each(function() {
        var item = parseFloat($(this).val());
        if (isNaN(item)) item = 0;

        total += item;
    });
	$('#lbl_total').html(total);
}); 

/*
function getId(id){
	$("#txt_get_id").val(id);
}

$(document).ready(function(){

$("#btnTest").click(function()
{
	
	var nil = "";
    nil = $('input:radio[name=user]:checked').val();
   $("#mst_client_id_1").val(nil);
   $("#client_name_1").val($('input:radio[name=user]:checked').attr('nama_client'));
}); 

$("#btnTest2").click(function()
{
	var id = $("#txt_get_id").val();
	var nil = "";
    nil = $('input:radio[name=get_nota]:checked').val();
   $("#no_nota_id_"+id).val(nil);
   $("#nota_note_"+id).val($('input:radio[name=get_nota]:checked').attr('nomor_nota'));
}); 

}); */
</script>